package com.luojialong.handle;


import com.luojialong.enums.AffairStatus;
import com.luojialong.exception.AffairException;
import com.luojialong.resultVo.ResultResponse;
import com.luojialong.utils.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandle {


    @ExceptionHandler(AffairException.class)
    public ResultResponse doHandle(AffairException exception) {
        log.info("affair error:" + exception);
        return ResultUtils.failure(exception);
    }

    @ExceptionHandler(RuntimeException.class)
    public ResultResponse doHandleRun(RuntimeException exception) {
        log.info("runtime error:" + exception);
        return ResultUtils.failure(AffairStatus.FAILURE,exception);
    }
 }
